/**
 * 
 */
package com.zte.claa.inficombo.csa.app.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author 0283000115
 * 
 *  csa.config.workmode=1
	csa.config.servicename=CSA
	csa.config.svrinstanceid=1
	csa.config.svrip=127.0.0.1
	csa.config.svrport=${server.port}
	csa.config.rptdatawokernum=3
	csa.config.extdatawokernum=2
	csa.config.rptdataqueuesize=20000
	csa.config.extdataqueuesize=10000
	csa.config.reauthwhenforcequit=y
	csa.config.publishrsplog=n
 *
 */

@Component  
@ConfigurationProperties(prefix="csa.config") 
public class CSAConfigProps {	
	public static final int WORKMODE_SINGLE = 1;
	public static final int WORKMODE_MULTI = 2;
	
	// 是否重认证。
	public static final String REAUTH_YES = "y";
	public static final String REAUTH_NO  = "n";
	// 是否发布异步响应信息到系统日志主题.
	public static final String PUBLISHRSP_YES = "y";
	public static final String PUBLISHRSP_NO  = "n";
	
	// 1=single node mode; >=2: multi-node mode;
	private int workmode = WORKMODE_SINGLE;
	private String servicename = "CSA";
	private String svrip = "127.0.0.1";
	private int svrport = 8098;
	private int svrinstanceid = 1;
	private int rptdatawokernum = 3;
	private int extdatawokernum = 2;
	private int rptdataqueuesize = 20000;
	private int extdataqueuesize = 10000;
	private String reauthwhenforcequit = REAUTH_YES;
	private String publishrsplog = PUBLISHRSP_NO;
	
	public String getServicename() {
		return servicename;
	}
	
	public void setServicename(String servicename) {
		this.servicename = servicename;
	}
	
	public String getSvrip() {
		return svrip;
	}
	
	public void setSvrip(String svrip) {
		this.svrip = svrip;
	}
	
	public int getSvrport() {
		return svrport;
	}
	
	public void setSvrport(int svrport) {
		this.svrport = svrport;
	}

	public int getSvrinstanceid() {
		return svrinstanceid;
	}

	public void setSvrinstanceid(int svrinstanceid) {
		this.svrinstanceid = svrinstanceid;
	}

	public int getWorkmode() {
		return workmode;
	}

	public void setWorkmode(int workmode) {
		this.workmode = workmode;
	}
	
	public boolean isSingleMode(){
		return this.workmode == WORKMODE_SINGLE;
	}

	public int getRptdatawokernum() {
		return rptdatawokernum;
	}

	public void setRptdatawokernum(int rptdatawokernum) {
		this.rptdatawokernum = rptdatawokernum;
	}

	public int getExtdatawokernum() {
		return extdatawokernum;
	}

	public void setExtdatawokernum(int extdatawokernum) {
		this.extdatawokernum = extdatawokernum;
	}

	public String getReauthwhenforcequit() {
		return reauthwhenforcequit;
	}

	public void setReauthwhenforcequit(String reauthwhenforcequit) {
		this.reauthwhenforcequit = reauthwhenforcequit;
	}

	public int getRptdataqueuesize() {
		return rptdataqueuesize;
	}

	public void setRptdataqueuesize(int rptdataqueuesize) {
		this.rptdataqueuesize = rptdataqueuesize;
	}

	public int getExtdataqueuesize() {
		return extdataqueuesize;
	}

	public void setExtdataqueuesize(int extdataqueuesize) {
		this.extdataqueuesize = extdataqueuesize;
	}

	public String getPublishrsplog() {
		return publishrsplog;
	}

	public void setPublishrsplog(String publishRsplog) {
		this.publishrsplog = (publishRsplog == null) ? PUBLISHRSP_NO : publishRsplog.trim();
	}
	
	public boolean checkPublishRspLog(){
		return PUBLISHRSP_YES.equalsIgnoreCase(this.publishrsplog);
	}
}
